﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

using System.Threading;
using System.Resources;
using System.Globalization;

namespace MobiMap.Admin
{
    public partial class ManageMap : System.Web.UI.Page
    {
        ResourceManager rm;
        CultureInfo ci;

        protected void Page_Load(object sender, EventArgs e)
        {
            //Tab active
            Label lbMapImage = (Label)Master.FindControl("tabMapImage");
            lbMapImage.CssClass = "tab_active";

            //div search
            HtmlControl divSearchPlace = (HtmlControl)Master.FindControl("divSearchPlace");
            divSearchPlace.Controls.Clear();

            //Check radio button            
            if (Application["mobimap_mapsource"] != null)
            {
                if ((int)Application["mobimap_mapsource"] == 0)
                {
                    google.Checked = true;
                    mapImage.Src = "../Image/GoogleMap.png";
                }
                else
                {
                    local.Checked = true;
                    mapImage.Src = "../Image/LocalMap.png";
                }
            }
            else
            {
                local.Checked = true;
                mapImage.Src = "../Image/LocalMap.png";
            }


            //Language
            //SetLanguage();
        }

        public void SetLanguage()
        {
            rm = new ResourceManager("Resources.SiteMap", System.Reflection.Assembly.Load("App_GlobalResources"));
            if (Request.Cookies["language"] != null)
            {
                string language = Request.Cookies["language"].Value;
                Thread.CurrentThread.CurrentCulture = new CultureInfo(language);
                LoadString(Thread.CurrentThread.CurrentCulture);

                return;
            }

            //Defaut language is Vietnamese
            Thread.CurrentThread.CurrentCulture = new CultureInfo("vi-VN");
            ci = Thread.CurrentThread.CurrentCulture;
            LoadString(ci);
        }

        public void LoadString(CultureInfo ci)
        {
            //lbFunctionTitle.Text = rm.GetString("Admin_FunctionAdd_Title", ci);
            //btnAdd.Text = rm.GetString("Admin_AddPlace_btnAdd", ci);
            //rm.GetString("Admin_AddService_Success", ci);
            //rm.GetString("Admin_AddService_Error", ci);
        }

        protected void btnChange_Click(object sender, EventArgs e)
        {
            int mapValue = int.Parse(hddChecked.Value);
            Application["mobimap_mapsource"] = mapValue;
            Response.Redirect(Request.Url.ToString());
        }
    }
}
